#!/bin/bash
version=`curl -s https://gitee.com/baihu433/termux-Yunzai/raw/master/version`
if [ "$version" != "1.0" ]; then
    rm -rf /usr/bin/bhyz
    wget https://gitee.com/baihu433/termux-Yunzai/raw/master/bhyz
    mv bhyz /usr/bin
    chmod +777 /usr/bin/bhyz
fi
if [ -d "~/Yunzai-Bot" ];then
  echo "您还没有安装云崽呢"
  exit
else
  echo "云崽已安装"
	echo "欢迎使用白狐云崽管理脚本"
fi
baihu=$(whiptail \
--title "白狐-Yunzai-Bot" \
--menu "您想配置什么？" \
0 50 0 \
"1" "启动Yunzai-Bot" \
"2" "停止Yunzai-Bot" \
"3" "查看Yunzai-Bot日志" \
"4" "完全重新配置账号" \
"5" "安装插件" \
"6" "打开安装脚本" \
"0" "退出程序" \
3>&1 1>&2 2>&3)

if [[ $baihu = 0 ]];then
   exit
fi

if [[ $baihu = 1 ]];then
  pushd ~/Yunzai-Bot/
  redis-server --daemonize yes
  node app
fi

if [[ $baihu = 2 ]];then
  pushd ~/Yunzai-Bot
  pnpm stop
fi

if [[ $baihu = 3 ]];then
  pushd ~/Yunzai-Bot
  pnpm run log
fi

if [[ $baihu = 4 ]];then
  pushd ~/Yunzai-Bot/config/config
  rm -rf other.yaml qq.yaml group.yaml redis.yaml
  pushd ~/Yunzai-Bot/data
  read -p "请输入您要重置的账号: " text
  case $text in
  $text)
  rm -rf $text --no-preserve-root
 esac
  echo -e '\033[36m 执行成功 \033[0m'
  pushd ~/Yunzai-Bot
  npm run login
fi

if [[ $baihu = 5 ]];then
  pushd ~/Yunzai-Bot
  bash <(curl -sL https://gitee.com/baihu433/termux-Yunzai/raw/master/plugin.sh)
  sleep 3s
fi

if [[ $baihu = 6 ]];then
   pushd ~/Yunzai-Bot
   bash <(curl -sL )
fi